
// 每个文件启动时执行
{
    function execute(){
        // 当前文件名
        const fileName = "Utils.js";
        console.log("执行文件名称为:" + fileName);
    }
    execute();
}


/**
 * 判断给定值的类型
 */
class TypeOfValueUtils{
    /**
     * 判断给定的值是否定义
     * @param value
     * @returns {boolean}
     * true:未定义
     * false:定义
     */
    static isUndefined(value){
        return (typeof value) == "undefined";
        // return value == undefined;
    }

    static isBoolean(value){
        return (typeof value) == "boolean";
    }

    static isString(value){
        return (typeof value) == "string";
    }

    static isNumber(value){
        return (typeof value) == "number";
    }

    static isInteger(value){
        // 下面是第1种方法判断
        // return (typeof value === 'number') && ( value % 1 === 0);
        return Number.isInteger(value);
    }

    static isObject(value){
        return (typeof value) == "object";
    }

    /**
     * 判断给定的值是否为函数
     * @param value
     * @returns {boolean}
     * true:是函数
     * false:不是函数
     */
    static isFunction(value){
        return (typeof value) == "function";
    }

    static is(value){
        return (typeof value) == "function";
    }











}

// 单元测试类
class TestUnitTypeOfValue2{

    static testUndefined(){
        let result;
        let value;

        console.log("================TestUnitTypeOfValue2.testUndefined() start...");
        {
            result = TypeOfValueUtils.isUndefined(value);
            console.log("value:" + value + ",result:" + result);
        }

        {
            value = "af";
            result = TypeOfValueUtils.isUndefined(value);
            console.log("value:" + value + ",result:" + result);
        }

        console.log("================TestUnitTypeOfValue2.testUndefined() end...");
    }

    static testIsInteger(){
        let result;
        let value;
        console.log("================TestUnitTypeOfValue2.testIsInteger() start...");
        {
            value = 1;
            result = TypeOfValueUtils.isInteger(value);
            console.log(" value:" + value + ",result:" + result);
        }

        {
            value = "af";
            result = TypeOfValueUtils.isInteger(value);
            console.log(" value:" + value + ",result:" + result);
        }
        console.log("================TestUnitTypeOfValue2.testIsInteger() end...");
    }

    static testIsFunction(){
        let result;
        let value;
        console.log("================TestUnitTypeOfValue2.testIsFunction() start...");
        {
            value = 1;
            result = TypeOfValueUtils.isFunction(value);
            console.log("value:" + value + ",result:" + result);
        }

        {
            function doIt(){

            }
            //
            value = doIt;
            result = TypeOfValueUtils.isFunction(value);
            console.log(" value:" + value + ",result:" + result);
        }
        console.log("================TestUnitTypeOfValue2.testIsFunction() end...");
    }



    static testAll(){
        TestUnitTypeOfValue2.testUndefined();
        TestUnitTypeOfValue2.testIsInteger();
        TestUnitTypeOfValue2.testIsFunction();
    }
}


TestUnitTypeOfValue2.testAll();

